package com.room.search.web.rest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import com.room.search.IntegrationTest;
import com.room.search.domain.RoomBasicProperty;
import com.room.search.repository.RoomBasicPropertyRepository;
import com.room.search.service.dto.RoomBasicPropertyDTO;
import com.room.search.service.mapper.RoomBasicPropertyMapper;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import javax.persistence.EntityManager;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

/**
 * Integration tests for the {@link RoomBasicPropertyResource} REST controller.
 */
@IntegrationTest
@AutoConfigureMockMvc
@WithMockUser
class RoomBasicPropertyResourceIT {

    private static final String DEFAULT_HOUSE_TYPE = "AAAAAAAAAA";
    private static final String UPDATED_HOUSE_TYPE = "BBBBBBBBBB";

    private static final String DEFAULT_BUILDING_SIZE = "AAAAAAAAAA";
    private static final String UPDATED_BUILDING_SIZE = "BBBBBBBBBB";

    private static final String DEFAULT_STRUCTURE = "AAAAAAAAAA";
    private static final String UPDATED_STRUCTURE = "BBBBBBBBBB";

    private static final String DEFAULT_ROOM_FLOOR = "AAAAAAAAAA";
    private static final String UPDATED_ROOM_FLOOR = "BBBBBBBBBB";

    private static final String DEFAULT_BUILDING_TYPE = "AAAAAAAAAA";
    private static final String UPDATED_BUILDING_TYPE = "BBBBBBBBBB";

    private static final String DEFAULT_LADDER_HOUSE_HOLD = "AAAAAAAAAA";
    private static final String UPDATED_LADDER_HOUSE_HOLD = "BBBBBBBBBB";

    private static final String DEFAULT_FLOOR_STRUCTURE = "AAAAAAAAAA";
    private static final String UPDATED_FLOOR_STRUCTURE = "BBBBBBBBBB";

    private static final String DEFAULT_ROOM_TOWARDS = "AAAAAAAA";
    private static final String UPDATED_ROOM_TOWARDS = "BBBBBBBB";

    private static final String DEFAULT_ROOM_FITMENT = "AAAAAAAA";
    private static final String UPDATED_ROOM_FITMENT = "BBBBBBBB";

    private static final String DEFAULT_LADDER_HOUSEHOLDS = "AAAAAAAAAA";
    private static final String UPDATED_LADDER_HOUSEHOLDS = "BBBBBBBBBB";

    private static final Boolean DEFAULT_LIFT = false;
    private static final Boolean UPDATED_LIFT = true;

    private static final String ENTITY_API_URL = "/api/room-basic-properties";
    private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}";

    private static Random random = new Random();
    private static AtomicLong count = new AtomicLong(random.nextInt() + (2 * Integer.MAX_VALUE));

    @Autowired
    private RoomBasicPropertyRepository roomBasicPropertyRepository;

    @Autowired
    private RoomBasicPropertyMapper roomBasicPropertyMapper;

    @Autowired
    private EntityManager em;

    @Autowired
    private MockMvc restRoomBasicPropertyMockMvc;

    private RoomBasicProperty roomBasicProperty;

    /**
     * Create an entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static RoomBasicProperty createEntity(EntityManager em) {
        RoomBasicProperty roomBasicProperty = new RoomBasicProperty()
            .houseType(DEFAULT_HOUSE_TYPE)
            .buildingSize(DEFAULT_BUILDING_SIZE)
            .structure(DEFAULT_STRUCTURE)
            .roomFloor(DEFAULT_ROOM_FLOOR)
            .buildingType(DEFAULT_BUILDING_TYPE)
            .ladderHouseHold(DEFAULT_LADDER_HOUSE_HOLD)
            .floorStructure(DEFAULT_FLOOR_STRUCTURE)
            .roomTowards(DEFAULT_ROOM_TOWARDS)
            .roomFitment(DEFAULT_ROOM_FITMENT)
            .ladderHouseholds(DEFAULT_LADDER_HOUSEHOLDS)
            .lift(DEFAULT_LIFT);
        return roomBasicProperty;
    }

    /**
     * Create an updated entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static RoomBasicProperty createUpdatedEntity(EntityManager em) {
        RoomBasicProperty roomBasicProperty = new RoomBasicProperty()
            .houseType(UPDATED_HOUSE_TYPE)
            .buildingSize(UPDATED_BUILDING_SIZE)
            .structure(UPDATED_STRUCTURE)
            .roomFloor(UPDATED_ROOM_FLOOR)
            .buildingType(UPDATED_BUILDING_TYPE)
            .ladderHouseHold(UPDATED_LADDER_HOUSE_HOLD)
            .floorStructure(UPDATED_FLOOR_STRUCTURE)
            .roomTowards(UPDATED_ROOM_TOWARDS)
            .roomFitment(UPDATED_ROOM_FITMENT)
            .ladderHouseholds(UPDATED_LADDER_HOUSEHOLDS)
            .lift(UPDATED_LIFT);
        return roomBasicProperty;
    }

    @BeforeEach
    public void initTest() {
        roomBasicProperty = createEntity(em);
    }

    @Test
    @Transactional
    void createRoomBasicProperty() throws Exception {
        int databaseSizeBeforeCreate = roomBasicPropertyRepository.findAll().size();
        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);
        restRoomBasicPropertyMockMvc
            .perform(
                post(ENTITY_API_URL)
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isCreated());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeCreate + 1);
        RoomBasicProperty testRoomBasicProperty = roomBasicPropertyList.get(roomBasicPropertyList.size() - 1);
        assertThat(testRoomBasicProperty.getHouseType()).isEqualTo(DEFAULT_HOUSE_TYPE);
        assertThat(testRoomBasicProperty.getBuildingSize()).isEqualTo(DEFAULT_BUILDING_SIZE);
        assertThat(testRoomBasicProperty.getStructure()).isEqualTo(DEFAULT_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomFloor()).isEqualTo(DEFAULT_ROOM_FLOOR);
        assertThat(testRoomBasicProperty.getBuildingType()).isEqualTo(DEFAULT_BUILDING_TYPE);
        assertThat(testRoomBasicProperty.getLadderHouseHold()).isEqualTo(DEFAULT_LADDER_HOUSE_HOLD);
        assertThat(testRoomBasicProperty.getFloorStructure()).isEqualTo(DEFAULT_FLOOR_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomTowards()).isEqualTo(DEFAULT_ROOM_TOWARDS);
        assertThat(testRoomBasicProperty.getRoomFitment()).isEqualTo(DEFAULT_ROOM_FITMENT);
        assertThat(testRoomBasicProperty.getLadderHouseholds()).isEqualTo(DEFAULT_LADDER_HOUSEHOLDS);
        assertThat(testRoomBasicProperty.getLift()).isEqualTo(DEFAULT_LIFT);
    }

    @Test
    @Transactional
    void createRoomBasicPropertyWithExistingId() throws Exception {
        // Create the RoomBasicProperty with an existing ID
        roomBasicProperty.setId(1L);
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        int databaseSizeBeforeCreate = roomBasicPropertyRepository.findAll().size();

        // An entity with an existing ID cannot be created, so this API call must fail
        restRoomBasicPropertyMockMvc
            .perform(
                post(ENTITY_API_URL)
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeCreate);
    }

    @Test
    @Transactional
    void getAllRoomBasicProperties() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        // Get all the roomBasicPropertyList
        restRoomBasicPropertyMockMvc
            .perform(get(ENTITY_API_URL + "?sort=id,desc"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(roomBasicProperty.getId().intValue())))
            .andExpect(jsonPath("$.[*].houseType").value(hasItem(DEFAULT_HOUSE_TYPE)))
            .andExpect(jsonPath("$.[*].buildingSize").value(hasItem(DEFAULT_BUILDING_SIZE)))
            .andExpect(jsonPath("$.[*].structure").value(hasItem(DEFAULT_STRUCTURE)))
            .andExpect(jsonPath("$.[*].roomFloor").value(hasItem(DEFAULT_ROOM_FLOOR)))
            .andExpect(jsonPath("$.[*].buildingType").value(hasItem(DEFAULT_BUILDING_TYPE)))
            .andExpect(jsonPath("$.[*].ladderHouseHold").value(hasItem(DEFAULT_LADDER_HOUSE_HOLD)))
            .andExpect(jsonPath("$.[*].floorStructure").value(hasItem(DEFAULT_FLOOR_STRUCTURE)))
            .andExpect(jsonPath("$.[*].roomTowards").value(hasItem(DEFAULT_ROOM_TOWARDS)))
            .andExpect(jsonPath("$.[*].roomFitment").value(hasItem(DEFAULT_ROOM_FITMENT)))
            .andExpect(jsonPath("$.[*].ladderHouseholds").value(hasItem(DEFAULT_LADDER_HOUSEHOLDS)))
            .andExpect(jsonPath("$.[*].lift").value(hasItem(DEFAULT_LIFT.booleanValue())));
    }

    @Test
    @Transactional
    void getRoomBasicProperty() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        // Get the roomBasicProperty
        restRoomBasicPropertyMockMvc
            .perform(get(ENTITY_API_URL_ID, roomBasicProperty.getId()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.id").value(roomBasicProperty.getId().intValue()))
            .andExpect(jsonPath("$.houseType").value(DEFAULT_HOUSE_TYPE))
            .andExpect(jsonPath("$.buildingSize").value(DEFAULT_BUILDING_SIZE))
            .andExpect(jsonPath("$.structure").value(DEFAULT_STRUCTURE))
            .andExpect(jsonPath("$.roomFloor").value(DEFAULT_ROOM_FLOOR))
            .andExpect(jsonPath("$.buildingType").value(DEFAULT_BUILDING_TYPE))
            .andExpect(jsonPath("$.ladderHouseHold").value(DEFAULT_LADDER_HOUSE_HOLD))
            .andExpect(jsonPath("$.floorStructure").value(DEFAULT_FLOOR_STRUCTURE))
            .andExpect(jsonPath("$.roomTowards").value(DEFAULT_ROOM_TOWARDS))
            .andExpect(jsonPath("$.roomFitment").value(DEFAULT_ROOM_FITMENT))
            .andExpect(jsonPath("$.ladderHouseholds").value(DEFAULT_LADDER_HOUSEHOLDS))
            .andExpect(jsonPath("$.lift").value(DEFAULT_LIFT.booleanValue()));
    }

    @Test
    @Transactional
    void getNonExistingRoomBasicProperty() throws Exception {
        // Get the roomBasicProperty
        restRoomBasicPropertyMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound());
    }

    @Test
    @Transactional
    void putNewRoomBasicProperty() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();

        // Update the roomBasicProperty
        RoomBasicProperty updatedRoomBasicProperty = roomBasicPropertyRepository.findById(roomBasicProperty.getId()).get();
        // Disconnect from session so that the updates on updatedRoomBasicProperty are not directly saved in db
        em.detach(updatedRoomBasicProperty);
        updatedRoomBasicProperty
            .houseType(UPDATED_HOUSE_TYPE)
            .buildingSize(UPDATED_BUILDING_SIZE)
            .structure(UPDATED_STRUCTURE)
            .roomFloor(UPDATED_ROOM_FLOOR)
            .buildingType(UPDATED_BUILDING_TYPE)
            .ladderHouseHold(UPDATED_LADDER_HOUSE_HOLD)
            .floorStructure(UPDATED_FLOOR_STRUCTURE)
            .roomTowards(UPDATED_ROOM_TOWARDS)
            .roomFitment(UPDATED_ROOM_FITMENT)
            .ladderHouseholds(UPDATED_LADDER_HOUSEHOLDS)
            .lift(UPDATED_LIFT);
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(updatedRoomBasicProperty);

        restRoomBasicPropertyMockMvc
            .perform(
                put(ENTITY_API_URL_ID, roomBasicPropertyDTO.getId())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isOk());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
        RoomBasicProperty testRoomBasicProperty = roomBasicPropertyList.get(roomBasicPropertyList.size() - 1);
        assertThat(testRoomBasicProperty.getHouseType()).isEqualTo(UPDATED_HOUSE_TYPE);
        assertThat(testRoomBasicProperty.getBuildingSize()).isEqualTo(UPDATED_BUILDING_SIZE);
        assertThat(testRoomBasicProperty.getStructure()).isEqualTo(UPDATED_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomFloor()).isEqualTo(UPDATED_ROOM_FLOOR);
        assertThat(testRoomBasicProperty.getBuildingType()).isEqualTo(UPDATED_BUILDING_TYPE);
        assertThat(testRoomBasicProperty.getLadderHouseHold()).isEqualTo(UPDATED_LADDER_HOUSE_HOLD);
        assertThat(testRoomBasicProperty.getFloorStructure()).isEqualTo(UPDATED_FLOOR_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomTowards()).isEqualTo(UPDATED_ROOM_TOWARDS);
        assertThat(testRoomBasicProperty.getRoomFitment()).isEqualTo(UPDATED_ROOM_FITMENT);
        assertThat(testRoomBasicProperty.getLadderHouseholds()).isEqualTo(UPDATED_LADDER_HOUSEHOLDS);
        assertThat(testRoomBasicProperty.getLift()).isEqualTo(UPDATED_LIFT);
    }

    @Test
    @Transactional
    void putNonExistingRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                put(ENTITY_API_URL_ID, roomBasicPropertyDTO.getId())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithIdMismatchRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                put(ENTITY_API_URL_ID, count.incrementAndGet())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithMissingIdPathParamRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                put(ENTITY_API_URL).contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void partialUpdateRoomBasicPropertyWithPatch() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();

        // Update the roomBasicProperty using partial update
        RoomBasicProperty partialUpdatedRoomBasicProperty = new RoomBasicProperty();
        partialUpdatedRoomBasicProperty.setId(roomBasicProperty.getId());

        partialUpdatedRoomBasicProperty
            .roomFloor(UPDATED_ROOM_FLOOR)
            .ladderHouseHold(UPDATED_LADDER_HOUSE_HOLD)
            .floorStructure(UPDATED_FLOOR_STRUCTURE)
            .roomTowards(UPDATED_ROOM_TOWARDS)
            .ladderHouseholds(UPDATED_LADDER_HOUSEHOLDS)
            .lift(UPDATED_LIFT);

        restRoomBasicPropertyMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedRoomBasicProperty.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(partialUpdatedRoomBasicProperty))
            )
            .andExpect(status().isOk());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
        RoomBasicProperty testRoomBasicProperty = roomBasicPropertyList.get(roomBasicPropertyList.size() - 1);
        assertThat(testRoomBasicProperty.getHouseType()).isEqualTo(DEFAULT_HOUSE_TYPE);
        assertThat(testRoomBasicProperty.getBuildingSize()).isEqualTo(DEFAULT_BUILDING_SIZE);
        assertThat(testRoomBasicProperty.getStructure()).isEqualTo(DEFAULT_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomFloor()).isEqualTo(UPDATED_ROOM_FLOOR);
        assertThat(testRoomBasicProperty.getBuildingType()).isEqualTo(DEFAULT_BUILDING_TYPE);
        assertThat(testRoomBasicProperty.getLadderHouseHold()).isEqualTo(UPDATED_LADDER_HOUSE_HOLD);
        assertThat(testRoomBasicProperty.getFloorStructure()).isEqualTo(UPDATED_FLOOR_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomTowards()).isEqualTo(UPDATED_ROOM_TOWARDS);
        assertThat(testRoomBasicProperty.getRoomFitment()).isEqualTo(DEFAULT_ROOM_FITMENT);
        assertThat(testRoomBasicProperty.getLadderHouseholds()).isEqualTo(UPDATED_LADDER_HOUSEHOLDS);
        assertThat(testRoomBasicProperty.getLift()).isEqualTo(UPDATED_LIFT);
    }

    @Test
    @Transactional
    void fullUpdateRoomBasicPropertyWithPatch() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();

        // Update the roomBasicProperty using partial update
        RoomBasicProperty partialUpdatedRoomBasicProperty = new RoomBasicProperty();
        partialUpdatedRoomBasicProperty.setId(roomBasicProperty.getId());

        partialUpdatedRoomBasicProperty
            .houseType(UPDATED_HOUSE_TYPE)
            .buildingSize(UPDATED_BUILDING_SIZE)
            .structure(UPDATED_STRUCTURE)
            .roomFloor(UPDATED_ROOM_FLOOR)
            .buildingType(UPDATED_BUILDING_TYPE)
            .ladderHouseHold(UPDATED_LADDER_HOUSE_HOLD)
            .floorStructure(UPDATED_FLOOR_STRUCTURE)
            .roomTowards(UPDATED_ROOM_TOWARDS)
            .roomFitment(UPDATED_ROOM_FITMENT)
            .ladderHouseholds(UPDATED_LADDER_HOUSEHOLDS)
            .lift(UPDATED_LIFT);

        restRoomBasicPropertyMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedRoomBasicProperty.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(partialUpdatedRoomBasicProperty))
            )
            .andExpect(status().isOk());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
        RoomBasicProperty testRoomBasicProperty = roomBasicPropertyList.get(roomBasicPropertyList.size() - 1);
        assertThat(testRoomBasicProperty.getHouseType()).isEqualTo(UPDATED_HOUSE_TYPE);
        assertThat(testRoomBasicProperty.getBuildingSize()).isEqualTo(UPDATED_BUILDING_SIZE);
        assertThat(testRoomBasicProperty.getStructure()).isEqualTo(UPDATED_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomFloor()).isEqualTo(UPDATED_ROOM_FLOOR);
        assertThat(testRoomBasicProperty.getBuildingType()).isEqualTo(UPDATED_BUILDING_TYPE);
        assertThat(testRoomBasicProperty.getLadderHouseHold()).isEqualTo(UPDATED_LADDER_HOUSE_HOLD);
        assertThat(testRoomBasicProperty.getFloorStructure()).isEqualTo(UPDATED_FLOOR_STRUCTURE);
        assertThat(testRoomBasicProperty.getRoomTowards()).isEqualTo(UPDATED_ROOM_TOWARDS);
        assertThat(testRoomBasicProperty.getRoomFitment()).isEqualTo(UPDATED_ROOM_FITMENT);
        assertThat(testRoomBasicProperty.getLadderHouseholds()).isEqualTo(UPDATED_LADDER_HOUSEHOLDS);
        assertThat(testRoomBasicProperty.getLift()).isEqualTo(UPDATED_LIFT);
    }

    @Test
    @Transactional
    void patchNonExistingRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, roomBasicPropertyDTO.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithIdMismatchRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, count.incrementAndGet())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithMissingIdPathParamRoomBasicProperty() throws Exception {
        int databaseSizeBeforeUpdate = roomBasicPropertyRepository.findAll().size();
        roomBasicProperty.setId(count.incrementAndGet());

        // Create the RoomBasicProperty
        RoomBasicPropertyDTO roomBasicPropertyDTO = roomBasicPropertyMapper.toDto(roomBasicProperty);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomBasicPropertyMockMvc
            .perform(
                patch(ENTITY_API_URL)
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomBasicPropertyDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the RoomBasicProperty in the database
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void deleteRoomBasicProperty() throws Exception {
        // Initialize the database
        roomBasicPropertyRepository.saveAndFlush(roomBasicProperty);

        int databaseSizeBeforeDelete = roomBasicPropertyRepository.findAll().size();

        // Delete the roomBasicProperty
        restRoomBasicPropertyMockMvc
            .perform(delete(ENTITY_API_URL_ID, roomBasicProperty.getId()).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent());

        // Validate the database contains one less item
        List<RoomBasicProperty> roomBasicPropertyList = roomBasicPropertyRepository.findAll();
        assertThat(roomBasicPropertyList).hasSize(databaseSizeBeforeDelete - 1);
    }
}
